package com.wtc.encapsulation;

public class AccountTest {
    public static void main(String[] args) {
        Account account = new Account();
        account.setName("make");
        account.setYE(50);
        account.setPasswd(781199);
        account.input();
    }
}
class Account {
    private String name;
    private int YE;
    private int passwd;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length() == 2 || name.length() == 3 || name.length() == 4) {
            this.name = name;
        } else {
            System.out.println("长度必须为2位、3位、4位，请重新设置，当前已赋予默认值：无");
            this.name = "无";
        }
    }

    public int getYE() {
        return YE;
    }

    public void setYE(int YE) {
        if (YE > 20) {
            this.YE = YE;
        } else {
            System.out.println("余额必须大于20，已赋予默认值：20");
            this.YE = 20;
        }

    }

    public int getPasswd() {
        return passwd;
    }

    public void setPasswd(int passwd) {
        String a = Integer.toString(passwd);
        if (a.length() == 6) {
            this.passwd = passwd;
        } else {
            System.out.println("密码必须是六位数！默认密码：123456");
            this.passwd = 123456;
        }
    }
    public void input() {
        System.out.println("账户信息：账户名称：" + name + "，账户余额" + YE + "，账户密码；" + passwd);
    }
}